﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.ComponentModel.DataAnnotations;
using System.Data.Entity.ModelConfiguration;

namespace Business.Models
{
    public class GiaoVien
    {
        [Key]
        [ForeignKey("NhanVien")]
        public int IdGiaoVien { get; set; }
        
        public virtual NhanVien NhanVien { get; set; }

    }

    public class GiaoVienConfiguration : EntityTypeConfiguration<GiaoVien>
    {

        public GiaoVienConfiguration()
            : base()
        {

            HasKey(d => d.IdGiaoVien);
            Property(d => d.IdGiaoVien).
                HasColumnName("IdGiaoVien").
                IsRequired();

            //HasRequired(x => x.NhanVien)
            //     .WithMany()
            //    .HasForeignKey(u => u.);

            //HasRequired(x => x.NhanVien).
            //WithMany().
            //    Map(x => x.MapKey("IdGiaoVien"));
            ToTable("GiaoVien", "dbo");
        }

    }
}